
#-*- coding:utf-8 -*-
from argparse import ArgumentParser,ArgumentError
from ShortMessage import MSG
def append_ride_ratio(parser):
    parser.add_argument("-r",dest="ride_ratio",metavar="0.N",type=float,default=0.1,help="gap-width/width between two pages in one paper,default 0.1")
def append_range_list(parser):
    parser.add_argument("-sr",dest="range_list",metavar="a-b,c-d",help="select the pages new books will contain,page starts from 1")
def append_split_list(parser):
    parser.add_argument("-ss",dest="split_list",metavar="a,b,c",help="split the INPUT_PDF into several books with the page point")
def append_cover_page(parser):
    parser.add_argument("-c",dest="cover_page",metavar="cover_page",type=int,default=-1,help="select cover page,specified page will be add to the first page,followed a blank page,.default is -1,which means no cover")
def append_output_pdf(parser):
    parser.add_argument("-o",dest="output_pdf",metavar="output_pdf",help="name for generated PDF file,if this was not given,add suffix '_result' to input_pdf name")
def append_margin_ratio(parser):
    parser.add_argument("-m",dest="margin_ratios",metavar="left,top,right,bottom",help="the margin width ratio for four side,order by left,top,right,bottom,values are in range (0 - 1),default not set")    
def append_input_pdf(parser):
    parser.add_argument("input_pdf",help="filename of pdf to be handled")
def append_fixcover_operation(parser):
    parser.add_argument("-x","--fix-cover",dest="fix_cover",metavar="book1,book2...",help="append blank page to cover page for specifing book index")
def getMakePrintablePdfParseResult(argvs):
    '''
    解析生成打印版pdf的输入参数
    '''
    parser = ArgumentParser()
    append_ride_ratio(parser)
    append_range_list(parser)
    append_split_list(parser)
    append_cover_page(parser)
    append_output_pdf(parser)
    append_margin_ratio(parser)
    append_input_pdf(parser)
    append_fixcover_operation(parser)
    return parser.parse_args(argvs[1:])

def getSplitPdfParseResult(argvs):
    '''
    解析拆分pdf参数
    '''
    parser = ArgumentParser()
    append_input_pdf(parser)
    append_range_list(parser)
    append_split_list(parser)
    append_output_pdf(parser)
    append_cover_page(parser)
    return parser.parse_args(argvs[1:])

def getCropPdfParseResult(argvs):
    '''
    解析切除边缘的参数
    '''
    parser = ArgumentParser()
    append_margin_ratio(parser)
    append_output_pdf(parser)
    append_input_pdf(parser)
    return parser.parse_args(argvs[1:])